﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
using td.Core;
using td.Core.DiscoverAddins;

namespace td.Addin
{
    public class SaveConfig:td.Core.AbstractToolButtonCommand
    {
        public override void Run()
        {
            var  p = WorkBenchSingleTon.WorkBench.GetTabPage("系统配置");
            SaveFileDialog save = new SaveFileDialog();
            save.Filter = "*.xml|*.xml";
            if (save.ShowDialog() == DialogResult.OK)
            {
                ((Addins)(p.ViewContentControl)).addin.SaveToFile(save.FileName);
            }
        }
        public override bool IsEnabled
        {
            get
            {
                var p = WorkBenchSingleTon.WorkBench.GetTabPage("系统配置");
                return p != null;
            }
            set
            {
                base.IsEnabled = value;
            }
        }
    }
}
